<?php
#                                                                                 
# author: Cody Sorgenfrey                                       
# (c)2013 South Hill Calvary Chapel                                               
# 
include_once("registrationManagerFunctions.php"); 
printf("<script type='text/javascript'>document.cookie = \"vars=%s_%s_%s\";</script>", $costPerPerson, $costPerCouple, $maxCost);
printf('<input type="hidden" id="itemName" name="item_name" value="%s Registration">', $title);
printf('<input type="hidden" id="itemNumber" name="item_number" value="shcc-%s">', $id);
printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/registrationManager.js'></script>");                                
?>
<style type="text/css">
	input[type="text"]
	{
		width:48%;
		max-width: 200px;
	}
	textarea
	{
		margin-top: -15px;
	}
</style>
<script type="text/javascript">
	function vbsAddMore()
	{
		if (document.getElementById("0-people").style.maxWidth != "600px"){
			document.getElementById("0-people").style.maxWidth = "600px";
		}
		var node = document.createElement("INPUT");
		node.type = "text";
		node.name = registration.formNumber+"-firstNames";
		node.placeholder = "Students First Name";
		var newNode = registration.extraFields.appendChild(node);
		var node2 = document.createElement("INPUT");
		node2.type = "text";
		node2.name = registration.formNumber+"-lastNames";
		node2.placeholder = "Students Last Name";
		registration.extraFields.appendChild(node2);
		var node4 = document.createElement("INPUT");
		node4.type = "text";
		node4.name = "dob";
		node4.placeholder = "DOB";
		registration.extraFields.appendChild(node4);
		var node6 = document.createElement("INPUT");
		node6.type = "text";
		node6.name = "alergies";
		node6.placeholder = "Alergies";
		registration.extraFields.appendChild(node6);
		newNode.addEventListener("keyup", countPeople, false);
	}
	function vbsPrepSubmit(id)
	{
		if (!vbsValidate()){
			return 0
		}
		for (var x=0;x<registration.numberRegistered;x++){
			registration.people[x] = document.getElementsByName(registration.formNumber+"-firstNames")[x].value;
			registration.people[x] += " " + document.getElementsByName(registration.formNumber+"-lastNames")[x].value;
		}
		if ((document.getElementById(registration.formNumber+"-notes").value != "Comments...") && (document.getElementById(registration.formNumber+"-notes").value !="")){
			registration.notes = "Notes...\r" + document.getElementById(registration.formNumber+"-notes").value + "\r\r";
		} 
		registration.notes += "Gaurdian: " + document.getElementById("0-gaurdianFirst").value + " " + document.getElementById("0-gaurdianLast").value + "\rInsurance Company: " + document.getElementById("0-insurance").value + "\rAddress: " + document.getElementById("0-address").value  + "\r\r";
		for (var x=0;x<registration.numberRegistered;x++){
			registration.notes += document.getElementsByName(registration.formNumber+"-firstNames")[x].value + "\rDOB: " + document.getElementsByName("dob")[x].value + "\rAlergies: " + document.getElementsByName("alergies")[x].value + "\r\r";
		}
		registration.newRegistration = 1;
		registration.checkOut = 0;
		if (registration.scholarship){
			if (registration.paymentType == null){
				registration.paymentType = "No payment made.";
				registration.scholarshipAmount = registration.amountDue;
				registration.amountDue = 0;
				registration.checkOut = 0;
				registration.paidInFull = 1;
			} else {
				registration.checkOut = 1;
			}
		}
		if (registration.free){
			registration.paymentType = "NA"
		}
		customSubmit(id);
	}
	function vbsValidate()
	{
		var x = "";
		if (document.getElementById("0-gaurdianFirst").value == ""){
			x += "Must have a gaurdian name to register\n";
		}
		if (registration.originalFirstName.value == ""){
			x += "Must have child's name to register\n";
		}
		if (document.getElementById("0-dob").value == ""){
			x += "Must have child's date of birth to register\n";
		}
		if (document.getElementById("0-insurance").value == ""){
			x += "Must have child's insurance company to register\n";
		}
		if (document.getElementById("0-address").value == ""){
			x += "Must have child's address to register\n";
		}
		if (document.getElementById("0-alergies").value == ""){
			x += "Must have child's alergies to register\n";
		}
		validateEmail(document.getElementById(registration.formNumber+"-email"));
		if (registration.email == ""){
			x += "Must have an email to register\n";
		}
		if (registration.phone.length != 12){
			x += "Must have a valid phone number to register\n";
		}
		if ((registration.paymentType == null) && (!registration.scholarship)){
			if (!registration.free){
				x += "Must select a payment type to register\n";
			}
		}
		if (x){
			alert(x);
			return 0;
		} else {
			return 1; 	
		}
	}

</script>
<form>
<input type='text' id='0-gaurdianFirst' name='0-gaurdian' placeholder='Gaurdians First'>
<input type='text' id='0-gaurdianLast' name='0-gaurdian' placeholder='Gaurdians Last'><br><br>
<input type='text' id='0-email' style='width:200px' onkeyup='validateEmail(this)' placeholder='Email'>
<span style='color:red;' id='0-email'></span><br><br>
Phone: <input type='text' maxlength='3' style='width:30px;' id='0-area' onkeyup='autoTab(this)'>
- <input type='text' maxlength='3' style='width:30px;' id='0-pre' onkeyup='autoTab(this)'>
- <input type='text' maxlength='4' style='width:40px;' id='0-post' onkeyup='registerPhone(this)'><br><br>
<input type='text' id='0-insurance' placeholder='Insurance Company'><br><br>
<textarea id='0-address' placeholder="Full Address" ></textarea><br><br>
<input type='text' id='0-firstNames' name='0-firstNames' placeholder='Student First Name' onkeyup='countPeople();'>
<input type='text' id='0-lastNames' name='0-lastNames' placeholder='Student Last Name'><br>
<input type='text' id='0-dob' name='dob' placeholder='DOB'>
<input type='text' id='0-alergies' name='alergies' placeholder='Alergies'>
<span style='font-size:12pt; cursor:pointer;' onclick='vbsAddMore();'>+ add more kids</span>
<div id='0-people' style='max-width:300px;'></div><br>
Amount Due: $<br><input type='text' id ='0-amountDue' name='amountDue' value='0.00' disabled='true'><br><br>
<input type='hidden' name='0-paymentType' value='Paypal'>
<input type='hidden' id='0-scholarship'>
<textarea id='0-notes' placeholder="Comments..."></textarea><br><br>
</form>                    
<p>By registering for this event I, the legal parent/guardian of the above named youth, give my permission to South Hill Calvary Chapel, Charles Gillaspie, and the leaders to seek and obtain necessary medical and emergency treatment and release them from liability for damages, losses, and injuries incident to this event. I have medical insurance for the above student.</p>
<?
printf('<input type="submit" border="0" value="Register" alt="PayPal - The safer, easier way to pay online!" onclick="vbsPrepSubmit(\'%s\')">', $id);
?>